<?php
	// R�cup�re le informations( nom, mdp,...) � partir de l'id de son id
	

        function model_view_playlist( $bdd, $playlist)
	{
		$playlist= $bdd->quote( $playlist);
		
		$results= $bdd->query(
			'SELECT playlists.playlist_name, playlist_sons.son_title
                        FROM playlists
                        INNER JOIN playlist_sons
                        ON playlists.id_playlist = playlist_sons.son_playlist'
                        
		);
		
		return $results->fetch( PDO::FETCH_ASSOC);
	}

        function model_insert_playlist( $bdd, $playlist)
	{
                $req = $bdd->prepare('INSERT INTO playlists(
                    playlist_name,
                    playlist_author,
                    playlist_type,
                    playlist_month,
                    playlist_description) 
                    
                    VALUES(
                    :playlist_name, 
                    :playlist_author, 
                    :playlist_type, 
                    :playlist_month, :playlist_description)');
                
                return ($req->execute($playlist)) ? $bdd->lastInsertId() : 0 ;
		
	
		 
                    echo 'La playlist a bien été ajouté !';
	}
        


	
	function model_user_informations( $bdd, $id_user)
	{
		$id_user= $bdd->quote( $id_user);
	
		$results= $bdd->query( 'SELECT * FROM `users` WHERE `id_user`='.$id_user);
	
		return $results->fetch( PDO::FETCH_OBJ);
	}
	

	
?>